<template>
  <div class="wechat-auth-page">
    <div class="auth-container">
      <div class="logo">
        <img
src="@/assets/logo.png" alt="系统Logo" />
      </div>

      <h2>微信授权登录</h2>
      <p class="tip">请授权获取您的微信信息以快速登录</p>

      <div v-if="userInfo"
class="user-info">
        <div class="avatar">
          <img
:src="userInfo.avatar" alt="微信头像" />
        </div>
        <div class="nickname">
          {{ userInfo.nickname }}
        </div>
      </div>

      <div class="auth-info">
        <div class="info-item">
          <img
src="@/assets/check-icon.png" alt="✓" />
          <span>获取您的公开信息（昵称、头像）</span>
        </div>
        <div class="info-item">
          <img
src="@/assets/check-icon.png" alt="✓" />
          <span>绑定您的微信账号</span>
        </div>
      </div>

      <button class="auth-btn"
@click="handleAuth">
        <img
src="@/assets/wechat-icon.png" alt="微信" />
        <span>微信授权登录</span>
      </button>

      <div class="other-options">
        <a href="#"
@click="switchToAccount">使用账号密码登录</a>
      </div>
    </div>
  </div>
</template>

<script setup>
  import { ref } from 'vue'

  const userInfo = ref(null)

  const handleAuth = () => {
    // 模拟获取微信用户信息
    userInfo.value = {
      nickname: '微信用户',
      avatar: '@/assets/wechat-avatar.png',
    }
    console.log('微信授权成功')
  }

  const switchToAccount = () => {
    console.log('切换到账号密码登录')
  }
</script>

<style scoped lang="scss">
  .wechat-auth-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7f7f7;

    .auth-container {
      width: 90%;
      max-width: 400px;
      background: white;
      border-radius: 12px;
      padding: 30px;
      box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
      text-align: center;

      .logo {
        margin-bottom: 20px;

        img {
          width: 80px;
          height: 80px;
          border-radius: 50%;
        }
      }

      h2 {
        margin: 0 0 10px 0;
        font-size: 20px;
        color: #333;
      }

      .tip {
        margin: 0 0 30px 0;
        font-size: 14px;
        color: #999;
      }

      .user-info {
        margin-bottom: 30px;

        .avatar {
          width: 80px;
          height: 80px;
          margin: 0 auto 10px;

          img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            border: 2px solid #f0f0f0;
          }
        }

        .nickname {
          font-size: 18px;
          font-weight: bold;
        }
      }

      .auth-info {
        text-align: left;
        margin: 25px 0;
        padding: 15px;
        background: #f9f9f9;
        border-radius: 8px;

        .info-item {
          display: flex;
          align-items: center;
          margin-bottom: 10px;

          &:last-child {
            margin-bottom: 0;
          }

          img {
            width: 16px;
            height: 16px;
            margin-right: 8px;
          }

          span {
            font-size: 14px;
            color: #666;
          }
        }
      }

      .auth-btn {
        width: 100%;
        padding: 12px;
        background: #07c160;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 20px;

        img {
          width: 24px;
          height: 24px;
          margin-right: 10px;
        }
      }

      .other-options {
        a {
          color: #1989fa;
          font-size: 14px;
          text-decoration: none;
        }
      }
    }
  }
</style>
